//
//  PaginatorCtr.swift
//  soapp
//
//  Created by zhu xietong on 2017/9/5.
//  Copyright © 2017年 CocoaPods. All rights reserved.
//

import Foundation
import Eelay
import JoLoading
import soapp

class PaginatorCtr: TableContainer {
    override func viewDidLoad() {
        self.page_load_section = "section0"
        self.content = TermsContainer.table(
            title: mo.model["name","商品列表".loc],
            emptyMsg:"没有相关内容",
            net: JoTask().post.url("http://apijson.cn:8080/get/").apijson(["[]":["Moment":["@column":"date,id,content,userid"]]]).log.log_response(),
            params:nil,//除了分页参数之外的额外参数
            node: "[]",
            cellType: Cell.self,
            cellHeigth: nil,
            detailType: nil,
            test: false
        )
        super.viewDidLoad()
        paginator.controlType = .UIRefreshControl
        tableView.buildDynamicHeight(height: 60)
        top_style = .light(with: UIColor(shex: "#71B780"))
        top_style.statusBarStyle = .lightContent
        reload_page()
        
        
    }
    
 
//    override func loadOnePage(list: [Any]) -> [Any] {
//        var new_list = [AnyObject]()
//        for (index,one) in list.enumerated()
//        {
//            if index%2 == 0
//            {
//                let dict = NSMutableDictionary()
//                dict["options"] = [one].mutable_array
//                new_list.append(dict)
//            }
//            else{
//                if let dict = new_list.last as? NSMutableDictionary{
//                    if let list = dict["options"] as? NSMutableArray
//                    {
//                        list.add(one)
//                    }
//                }
//            }
//        }
//        return new_list
//    }

}
extension PaginatorCtr
{
    class Cell: JoTableCell {
        let nameL = UILabel()
        override func addLayoutRules() {
            contentView.eelay = [
                [nameL,[ee.T.L.B.R,[30,10,-30,-10]]]
            ]
        }
        
        override func mo_model_reload() {
            nameL.text = mo.model["Moment.content",""] + mo.model["Moment.date",""]
        }
    }
}

